Skip to content

fix(ssh): loosen agent server keep-alive to survive brief network stalls - #760

Merged
skevetter merged 2 commits into
mainfrom
greedy-hound
Jul 26, 2026
Merged

fix(ssh): loosen agent server keep-alive to survive brief network stalls#760
skevetter merged 2 commits into
mainfrom
greedy-hound

Conversation

@skevetter

Copy link
Copy Markdown
Contributor

Fixes #759

Summary

The host agent SSH server (NewServer, run as ssh-server --stdio — the ProxyCommand target) hardcoded its connection-level keep-alive to ClientAliveInterval: 5s, ClientAliveCountMax: 2 — a ~10s tolerance. That is an order of magnitude stricter than OpenSSH, so a brief network stall (e.g. the reported 39s) that a plain ssh session rides through closed the transport, which killed the container tunnel and tore down the user's SSH session.

This defaults the tolerance to ~120s (15s × 8), mirroring OpenSSH's ServerAliveInterval 30 × ServerAliveCountMax 4, and makes both knobs configurable via DEVSY_SSH_KEEPALIVE_INTERVAL (Go duration or bare seconds) and DEVSY_SSH_KEEPALIVE_COUNT_MAX. Invalid/non-positive values fall back to the defaults.

Relaxing the keep-alive is safe for the socket-cleanup path it was added for: stale per-connection agent socket dirs from genuinely dead peers are still reclaimed on server start via SweepStaleAgentSockets().

Out of scope

The secondary port-forward leak from #759 (bind: address already in use on reconnect) is not addressed here — it needs separate tracing of the reconnect path.

The host agent SSH server closed the transport after ~10s (5s x 2) of
missed keep-alives, far stricter than OpenSSH, so short network stalls
tore down the tunnel and the user's SSH session. Default the tolerance
to ~120s (15s x 8, OpenSSH-like) and make it configurable via
DEVSY_SSH_KEEPALIVE_INTERVAL and DEVSY_SSH_KEEPALIVE_COUNT_MAX.

Fixes #759
@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@skevetter, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 59 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5575f6b0-4ed1-4933-b4e9-2a204acc1aaf

📥 Commits

Reviewing files that changed from the base of the PR and between 5311f4e and b11c9d5.

📒 Files selected for processing (2)
  • pkg/ssh/server/ssh.go
  • pkg/ssh/server/ssh_test.go

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@netlify

netlify Bot commented Jul 26, 2026

Copy link
Copy Markdown

👷 Deploy Preview for images-devsy-sh processing.

Name Link
🔨 Latest commit eba5f93
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6a6622b730840f0008ee73ac

@netlify

netlify Bot commented Jul 26, 2026

Copy link
Copy Markdown

Deploy Preview for images-devsy-sh canceled.

Name Link
🔨 Latest commit b11c9d5
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6a6624656d677a0008355f0f

@netlify

netlify Bot commented Jul 26, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit b11c9d5
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a662465ab50eb0008f53b51

@skevetter
skevetter marked this pull request as ready for review July 26, 2026 16:26
@skevetter
skevetter merged commit 2b3ddf2 into main Jul 26, 2026
65 checks passed
@skevetter
skevetter deleted the greedy-hound branch July 26, 2026 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SSH tunnel torn down on brief network stalls: internal keep-alive closes the transport after 2 intervals, while plain ssh survives the same pause

1 participant